<%@ page import="java.util.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>学生列表</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#go").click(function () {
                $("form #pageNo").val($(this).prev().val());
                $("#studentForm").submit();
                //return false;
            });

            $(".pager a").click(function () {
                $("form #pageNo").val($(this).attr("data-no"));
                $("#studentForm").submit();
                return false;
            });
            $("#search").click(function () {
                $("form #pageNo").val(1);
                return true;
            });
        });
    </script>
</head>
<body>
<div>
   <%-- <%
        Enumeration<String> er = request.getAttributeNames();
        while (er.hasMoreElements()){
            out.print(er.nextElement()+"===<br/>");
        }

        java.util.Map<String,String[]> map=request.getParameterMap();
        Iterator<Map.Entry<String, String[]>> ir = map.entrySet().iterator();
        while (ir.hasNext()){
            Map.Entry<String, String[]> mr=ir.next();
            out.print(mr.getKey()+"=="+ Arrays.toString(mr.getValue())+"<br/>");
        }
    %>--%>
    <form action="search" method="get" id="studentForm">
        <input type="hidden" name="pageNo" id="pageNo" value="1">
        姓名：<input type="search"  name="sname" value="${sname}"/>
        QQ：<input  type="search" name="qq" value="${qq}"/>
        手机号：<input  type="search" name="telephone" value="${telephone}"/>

        入学时间从<input type="date" name="startDate" value="<fmt:formatDate value='${startDate}' pattern='yyyy-MM-dd'/>"/>到
                  <input type="date" name="endDate" value="<fmt:formatDate value='${endDate}' pattern='yyyy-MM-dd'/>"/>
        <input type="submit" value="搜索" id="search"/>
        <a href="toAdd">添加新生</a>
    </form>
</div>
<table border="1" cellpadding="0" cellspacing="0">
    <tr>
        <th>学号</th><th>姓名</th><th>手机号</th><th>QQ</th><th>入学时间</th><th>操作</th>
    </tr>

    <c:forEach items="${p.data}" var="stu">
    <tr>
        <td>${stu.stuno}</td>
        <td>${stu.sname}</td>
        <td>${stu.telephone}</td>
        <td>${stu.qq}</td>
        <td>${stu.enterdate}</td>
        <td><a href="#">Xiugai</a><a href="#">delete</a>
            <a href="showstu.cmd?stuno=${stu.stuno}">查看全部信息</a>
            <a href="#">查看成绩</a>
        </td>
    </tr>
    </c:forEach>

</table>
<p class="pager">
    <%--<a href="subjectServlet?pageNo=1&sname=<%=%>&qq=&telephone">首页</a>--%>
    <a href="search?pageNo=1" data-no="1">首页</a>

        <c:if test="${p.pageNo>1}">
    <a href="search?pageNo=${p.pageNo-1}" data-no="${p.pageNo-1}">上一页</a>
        </c:if>
    <input type="number" min="1" value="${p.pageNo}" max="${p.totalPages}" name="pageNo" width="40px" size="4"/><input type="button" id="go" value="go" style="width: 60px;"/>


    <c:if test="${p.pageNo<p.totalPages}">
    <a href="search?pageNo=${p.pageNo+1}"  data-no="${p.pageNo+1}">下一页</a>
    </c:if>
    <a href="search?pageNo=${p.totalPages}" data-no="${p.totalPages}">最后一页</a>
</p>
</body>
</html>
